<link rel="stylesheet" href="__CDN__/assets/addons/groupon/libs/element/element.css">
<link rel="stylesheet" href="__CDN__/assets/addons/groupon/libs/common.css">
<style>
    .common-refresh-button {
        margin-bottom: 20px;
    }

    .order-table {
        padding: 20px 0 0;
        background: #fff;
        margin-top: 10px;
    }

    .order-table .el-table {
        color: #999;
        font-size: 12px;
    }

    /* 中间部分 */
    .order-table .el-table__row td {
        background: #F9F9F9 !important;
        height: 30px !important;
        padding: 0;
    }

    .order-table .el-table__expanded-cell[class*=cell] {
        padding: 0;
    }

    /* 多余的border */
    .order-table .el-table--border td,
    .order-table .el-table--border th,
    .order-table .el-table__body-wrapper .el-table--border.is-scrolling-left~.el-table__fixed {
        border-left: none;
        border-right: none;
    }

    .order-table .el-table--border {
        border-left: none;
    }

    .order-table .el-table::before,
    .el-table__fixed-right::before,
    .el-table__fixed::before {
        height: 0;
    }

    .order-table .el-table td,
    .order-table .el-table th.is-leaf {
        border-bottom: none;
    }
    .order-table .el-table__empty-block {
        border: 1px solid #e6e6e6;
    }
    .el-table_1_column_1 {
        border-left: 1px solid #e6e6e6 !important;
    }

    .el-table_1_column_9 {
        border-right: 1px solid #e6e6e6 !important;
    }

    .order-table .el-table td {
        padding: 0;
        border-top: 1px solid #E6E6E6;
    }

    .margin-right-10 {
        margin-right: 10px;
    }

    .expand-item-container {
        margin-bottom: 8px;
        color: #444;
        width: 100%;
        font-size: 13px;
    }

    .expand-item {
        /* height: 80px; */
        width: 104px;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .expand-item-item {
        height: 80px;
        border-bottom: 1px solid #E6E6E6;
        padding: 16px 14px 14px;
        width: 100%;
    }

    .expand-item-1 {
        width: 633px;
        border-left: 1px solid #E6E6E6;
        flex-direction: column;
    }

    .goods-image {
        width: 50px;
        height: 50px;
        margin-right: 14px;
    }

    .goods-title {
        margin-bottom: 12px;
        text-align: left;
    }

    .expand-item-2 {
        flex-direction: column;
    }

    .expand-item-3 {
        width: 94px;
    }

    .expand-item-5 {
        width: 114px;
        padding: 0 10px;
    }

    .expand-item-7 {
        width: 136px;
    }

    .expand-item-8 {
        flex: 1;
        min-width: 80px;
        text-align: center;
    }

    .pay-type {
        padding: 0 5px;
        border-radius: 4px;
        display: block;
        border: 1px solid #B698E7;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .pay-type-wallet {
        border-color: #B698E7;
        background: #E9E2F5;
        color: #8A44FC;
    }

    .pay-type-wechat {
        border-color: #A2E8C4;
        background: #E4F5EC;
        color: #4AD88E;
    }

    /* popover */
    .popover-item {
        height: 30px;
    }

    .popover-item-title {
        width: 50px;
        display: block;
    }

    .user-avatar {
        width: 26px;
        height: 26px;
        border-radius: 50%;
    }

    .user-id {
        border-bottom: 1px solid #7438D5;
        height: 24px;
        line-height: 24px;
        cursor: pointer;
        color: #7438D5;
    }

    .user-nickname {
        /* border-bottom: 1px solid #7438D5; */
        color: #7438D5;
        height: 30px;
        line-height: 30px;
        width: 80px;
        text-align: center;
    }

    .consignee-item {
        width: 80px;
        margin-bottom: 12px;
    }

    /* operation */
    .operation-container .el-dialog {
        width: 600px;
    }

    .operation-container .el-dialog__body {
        padding-top: 20px;
        padding-bottom: 20px;
    }

    .operation-container .el-table th {
        padding: 5px 0;
    }

    .operation-container .el-table .cell {
        justify-content: center;
    }

    .operation-container .el-table td,
    .operation-container .el-table th.is-leaf {
        border-bottom: 1px solid #e6e6e6;
    }

    .operation-container .el-table--border td,
    .operation-container .el-table--border th {
        border-right: none;
    }

    [v-cloak] {
        display: none
    }
</style>
<script src="__CDN__/assets/addons/groupon/libs/vue.js"></script>
<script src="__CDN__/assets/addons/groupon/libs/element/element.js"></script>
<script src="__CDN__/assets/addons/groupon/libs/moment.js"></script>
<div id="orderIndex" v-cloak>
    <div class="screen-reset-container">
        <div class="common-refresh-button" @click="goOrderRefresh">
            <i class="el-icon-refresh" :class="focusi?'focusi':''"></i>
        </div>
        <div class="screen-reset-item">
            <div class="screen-reset-item-radio">
                <el-radio-group v-model="searchForm.status" fill="#7536D0" @change="reqOrderList(0,10)" size="small">
                    <el-radio-button label="all">全部</el-radio-button>
                    <el-radio-button label="cancel">已取消</el-radio-button>
                    <el-radio-button label="invalid">交易关闭</el-radio-button>
                    <el-radio-button label="nopay">待付款</el-radio-button>
                    <el-radio-button label="payed">已支付</el-radio-button>
                    <el-radio-button label="nosend">待备货</el-radio-button>
                    <el-radio-button label="noget">待自提</el-radio-button>
                    <el-radio-button label="finish">已完成</el-radio-button>
                    <el-radio-button label="refund">退款</el-radio-button>
                </el-radio-group>
            </div>
        </div>
        <div class="screen-reset-item">
            <div class="screen-reset-item-title">下单时间</div>
            <div class="screen-reset-item-time">
                <el-date-picker v-model="searchForm.createtime" type="daterange" value-format="yyyy-MM-dd HH:mm:ss"
                    format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
                    @change="reqOrderList(0,10)" size="small" :default-time="['00:00:00', '23:59:59']">
                </el-date-picker>
            </div>
        </div>
        <div class="screen-reset-item">
            <div class="screen-reset-item-iselect">
                <el-input placeholder="请输入内容" v-model="searchForm.form_1_value" class="input-with-select" size="small">
                    <el-select v-model="searchForm.form_1_key" slot="prepend" placeholder="请选择">
                        <el-option label="订单编号" value="order_sn"></el-option>
                        <el-option label="订单ID" value="id"></el-option>
                        <el-option label="支付单号" value="transaction_id"></el-option>
                    </el-select>
                </el-input>
            </div>
        </div>
        <div class="screen-reset-item">
            <div class="screen-reset-item-iselect">
                <el-input placeholder="请输入内容" v-model="searchForm.form_2_value" class="input-with-select" size="small">
                    <el-select v-model="searchForm.form_2_key" slot="prepend" placeholder="请选择">
                        <el-option label="会员ID" value="user_id"></el-option>
                        <el-option label="会员昵称" value="nickname"></el-option>
                        <el-option label="手机号" value="user_phone"></el-option>
                        <el-option label="取货人" value="consignee"></el-option>
                        <el-option label="取货人手机号" value="phone"></el-option>
                    </el-select>
                </el-input>
            </div>
        </div>
        <div class="screen-reset-item">
            <div class="screen-reset-item-title">支付方式</div>
            <div class="screen-reset-item-input">
                <el-select v-model="searchForm.pay_type" placeholder="请选择支付方式" size="small">
                    <el-option :label="pay.name" :value="pay.type" v-for="pay in orderScreenList.pay_type">
                    </el-option>
                </el-select>
            </div>
        </div>
        <div class="screen-reset-item">
            <div class="screen-reset-item-title">自提点订单</div>
            <div class="screen-reset-item-select">
                <el-select style="position: relative;" v-model="searchForm.store_id" filterable placeholder="请选择自提点"
                    :filter-method="dataFilter" size="small">
                    <el-option v-for="item in selectStoreList" :key="item.name" :label="item.name" :value="item.id+''">
                        <div class="display-flex" style="width: 300px;">
                            <span style="width: 60px;text-align: center;flex-shrink: 0;">{{ item.id }}</span>
                            <div class="ellipsis-1" style="width: 80px;flex-shrink: 0;">{{ item.name }}</div>
                            <div class="ellipsis-1" style="width: 140px;">
                                {{item.province_name}}{{item.city_name}}{{item.area_name}}{{item.address}}
                            </div>
                        </div>
                    </el-option>
                </el-select>
            </div>
        </div>
        <div class="screen-reset-item">
            <div class="screen-reset-item-title">商品名称</div>
            <div class="screen-reset-item-input">
                <el-input placeholder="请输入商品名称" v-model="searchForm.goods_title" size="small"></el-input>
            </div>
        </div>
        <div class="screen-reset-item">
            <div class="common-button common-reset-button" @click="screenEmpty">重置</div>
            <div class="common-button common-screen-button" @click="reqOrderList(0,10)">筛 选</div>
        </div>
    </div>
    <div class="order-table">
        <div class="common-table-container common-table-container-expand">
            <el-table :data="orderList" border default-expand-all="true">
                <el-table-column type="expand">
                    <template slot-scope="props">
                        <div class="expand-item-container display-flex">
                            <div class="expand-item expand-item-1 border-right">
                                <div class="expand-item-item display-flex" v-for="(item,index) in props.row.item">
                                    <div class="goods-image" v-if="item.goods_image">
                                        <el-image :src="Fast.api.cdnurl(item.goods_image)" fit="cover">
                                            <div slot="error" class="image-slot">
                                                <i class="el-icon-picture-outline"></i>
                                            </div>
                                        </el-image>
                                    </div>
                                    <div>
                                        <div class="goods-title ellipsis-item">{{item.goods_title}}</div>
                                        <div class="color-999 display-flex">
                                            <span class="margin-right-10" v-if="item.goods_sku_text">规格：{{item.goods_sku_text}}</span>
                                            <span class="margin-right-10">单价：{{item.goods_price}}元</span>
                                            <span>数量：{{item.goods_num}}</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="expand-item expand-item-2 border-right">
                                <div class="expand-item-item display-flex-c" v-for="(item,index) in props.row.item">
                                    <span v-if="props.row.status>0">{{item.status_name}}</span>
                                    <span v-if="props.row.status<=0">-</span>
                                </div>
                            </div>
                            <div class="expand-item expand-item-3 border-bottom border-right"
                                :style="{'height': props.row.item.length*80+'px'}">
                                <span :class="props.row.status<0?'color-999':'color-444'">
                                    {{props.row.status_text}}
                                </span>
                            </div>
                            <div class="expand-item expand-item-4 border-bottom border-right"
                                :style="{'height': props.row.item.length*80+'px'}">
                                <template v-if="props.row.user">
                                    <el-popover placement="bottom" width="200" height="80" trigger="hover">
                                        <div class="popover-container">
                                            <div class="popover-item display-flex">
                                                <span class="popover-item-title">头像</span><span>:</span>
                                                <img class="user-avatar margin-left-10"
                                                    :src="Fast.api.cdnurl(props.row.user.avatar)">
                                            </div>
                                            <div class="popover-item display-flex">
                                                <span class="popover-item-title">ID</span><span>:</span>
                                                <span class="user-id margin-left-10"
                                                    @click="goOrderUser(props.row.user.id)">
                                                    {{props.row.user?props.row.user.id:''}}
                                                </span>
                                            </div>
                                            <div v-if="props.row.user.mobile" class="popover-item display-flex">
                                                <span class="popover-item-title">手机号</span><span>:</span>
                                                <span class="margin-left-10">{{props.row.user.mobile}}</span>
                                            </div>
                                        </div>
                                        <div slot="reference">
                                            <div class="user-nickname color-666 ellipsis-item"
                                                v-if="props.row.user.nickname" @click="goOrderUser(props.row.user.id)">
                                                {{props.row.user.nickname}}
                                            </div>
                                            <div class="user-nickname color-666 ellipsis-item" v-else
                                                @click="goOrderUser(props.row.user.id)">
                                                无昵称
                                            </div>
                                        </div>
                                    </el-popover>
                                </template>
                                <span v-else>{{props.row.user_id}}</span>
                            </div>
                            <div class="expand-item expand-item-5 border-bottom border-right"
                                :style="{'height': props.row.item.length*80+'px'}">
                                <div class="ellipsis-item" v-if="props.row.store">{{props.row.store.name}}</div>
                                <span v-else>{{props.row.store_id}}</span>
                            </div>
                            <div class="expand-item expand-item-6 border-bottom border-right"
                                :style="{'height': props.row.item.length*80+'px'}">
                                <div v-if="props.row.consignee">
                                    <div class="consignee-item color-666 ellipsis-1">
                                        {{props.row.consignee}}
                                    </div>
                                    <div class="color-666">{{props.row.phone}}</div>
                                </div>
                                <div v-if="!props.row.consignee">-</div>
                            </div>
                            <div class="expand-item expand-item-7 border-bottom border-right"
                                :style="{'height': props.row.item.length*80+'px'}" style="width: 136px;">
                                <span>{{props.row.pay_fee}}<span class="common-unit">元</span></span>
                            </div>
                            <div class="expand-item expand-item-8 border-bottom border-right"
                                :style="{'height': props.row.item.length*80+'px'}">
                                <span class="theme-color cursor-pointer" @click.stop="goDetail(props.row.id)">
                                    查看详情
                                </span>
                            </div>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column width="585" label="商品信息">
                    <template slot-scope="scope">
                        <div class="display-flex">
                            <span class="margin-right-10 color-444">ID:{{scope.row.id}}</span>
                            <span class="margin-right-10">
                                订单号:{{scope.row.order_sn}}
                                <span v-if="scope.row.createtime">
                                    下单时间:{{moment(scope.row.createtime*1000).format('YYYY-MM-DD HH:mm:ss')}}
                                </span>
                            </span>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column width="104" label="发货状态" align="center">
                    <template slot-scope="scope">
                        <span v-if="scope.row.pay_type=='wallet'"
                            class="pay-type pay-type-wallet">{{scope.row.pay_type_text}}</span>
                        <span v-if="scope.row.pay_type=='wechat'"
                            class="pay-type pay-type-wechat">{{scope.row.pay_type_text}}</span>
                    </template>
                </el-table-column>
                <el-table-column width="94" label="订单状态" align="center">
                </el-table-column>
                <el-table-column width="104" label="下单用户" align="center">
                </el-table-column>
                <el-table-column width="114" label="所属自提点" align="center">
                </el-table-column>
                <el-table-column width="104" label="取货信息" align="center">
                </el-table-column>
                <el-table-column width="136" label="支付金额(元)" align="center">
                </el-table-column>
                <el-table-column fixed="right" label="操作" align="center">
                    <template slot-scope="scope">
                        <div class="theme-color cursor-pointer" @click="optRecord(scope.row.id)">操作日志</div>
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <div class="common-pagination-container">
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="currentPage" :page-sizes="[10, 20, 30, 40]" :page-size="limit"
                layout="total, sizes, prev, pager, next, jumper" :total="totalPage">
            </el-pagination>
        </div>
    </div>
    <!-- 操作日志 -->
    <div class="operation-container">
        <el-dialog title="操作日志" :visible.sync="optRecordDialog">
            <el-table :data="optList" border>
                <el-table-column property="remark" label="事件"></el-table-column>
                <el-table-column property="oper.name" label="员工" width="100"></el-table-column>
                <el-table-column property="createtime" width="200" label="时间">
                    <template slot-scope="scope">
                        <span>{{moment(scope.row.createtime*1000).format("YYYY-MM-DD HH:mm:ss")}}</span>
                    </template>
                </el-table-column>
            </el-table>
        </el-dialog>
    </div>
</div>